package com.intellagric.agriecom.service.recommend.service;


import com.intellagric.agriecom.module.recommend.ProductRecommendServiceIN;
import com.intellagric.mapper.AgriecomProduceMapper;
import com.intellagric.pojo.AgriecomProduce;
import com.intellagric.pojo.AgriecomProduceExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: zhy
 * @Date: 2019/5/9
 * @Description: 用户推荐模块的商品信息服务
 */
@Service
public class ProductRecommendService implements ProductRecommendServiceIN {

    @Autowired
    private AgriecomProduceMapper productMapper;

    /**
     * 查询包含productIdList集合的商品信息
     *
     * @param productIdList 商品id列表
     * @return List<Product>
     */
    public List<AgriecomProduce> baseInfo(List<String> productIdList) {
        if (productIdList != null && productIdList.size() > 0) {
            AgriecomProduceExample productExample = new AgriecomProduceExample();
            productExample.createCriteria().andProduceIdIn(productIdList);
            List<AgriecomProduce> products = productMapper.selectByExample(productExample);
            return products;
        } else {
            return new ArrayList<>();
        }

    }

}
